#include "com.h"
#include "uart.h"
#include <stdlib.h>
#include <string.h>
#include "iap_update.h"
#include "ymodem.h"

com_info_t com_info;

void com_service(void)
{
  com_dev_t *p_com;
  p_com = com_list_head;
  while(p_com != NULL) {
    com_info.size = p_com->read(com_info.cache, 1024);
    if(com_info.size == 0) {
      p_com = p_com->next;
      continue;
    }
    com_info.handler = (uint32_t)p_com;
    if(!iap_service(com_info.cache, com_info.size, com_info.handler)) goto next;
    if(!ymodem_service(com_info.cache, com_info.size, com_info.handler)) goto next;
next:
    p_com = p_com->next;
  }
}
